package com.sl.plugin.step.selenium.notice;

import com.sl.core.engine.meta.impl.AbstractProcessCompDescriptor;
import com.sl.core.engine.step.ProcessCompService;
import com.sl.core.engine.step.impl.AbstractProcessComp;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;

/**
 */
public class SeleniumNoticeComp extends AbstractProcessComp<WebDriver, WebDriver> implements ProcessCompService {


    public SeleniumNoticeComp(AbstractProcessCompDescriptor abstractProcessCompDescriptor) {
        super(abstractProcessCompDescriptor);
    }


    @Override
    public WebDriver input(WebDriver driver) {
        String time = meta.getStrAttr("title");
        String body =  meta.getStrAttr("body");
        String icon =  meta.getStrAttr("icon");

       String notice =  "new Notification(\""+time+"\", { body: \""+body+"\", icon: \""+icon+"\"," +
               " data: \"\"});";
        JavascriptExecutor js = (JavascriptExecutor) driver;
        Object o = js.executeScript(notice);
        return driver;
    }

}
